package sh.wn36.vehiclemanage.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import sh.wn36.vehiclemanage.entity.Dictionary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import sh.wn36.vehiclemanage.xzh.DictionaryInfo;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xk
 * @since 2021-04-26
 */
public interface DictionaryMapper extends BaseMapper<Dictionary> {
    @Select("select text from dictionary where lev = 1 ")
    List<String> getLargeList();

    @Select("select * from dictionary where  text = #{largeClassification,jdbcType=VARCHAR} ")
    Dictionary getByTest(@Param("largeClassification") String largeClassification);

    @Select("select *  from dictionary where pid = #{id} and lev = #{lev}" )
    List<Dictionary> getByPidAndLev(@Param("id") Integer id,@Param("lev")Integer lev);

    @Select("select * from dictionary where lev = #{lev}")
    List<Dictionary> getListByLev(@Param("lev") int lev);

    @Select("select * from dictionary where id = #{pid}")
    List<Dictionary> getListBySonPid(@Param("pid") Integer pid);

    @Select("select * from dictionary where pid = #{id}")
    List<Dictionary> getByPid(@Param("id")Integer id);

    @Select("select * from dictionary where pid = #{pid}")
    List<Dictionary> getPid(int i);
    @ApiModelProperty("根据部门查id")
        @Select("select * from dictionary where text= #{name}")
      Dictionary finddept (String name);


    @Select("select d1.*,d2.text as ptext from dictionary d1 \n" +
            "LEFT JOIN dictionary d2 on d2.id = d1.pid")
    IPage<DictionaryInfo> getList(Page<DictionaryInfo> page);

    @Select("select d1.*,d2.text  as ptext from dictionary d1 \n" +
            "LEFT JOIN dictionary d2 on d2.id = d1.pid\n" +
            "where d2.text = #{text}  or d1.text = #{text}\n ")
    IPage<DictionaryInfo> getListByMini(Page<DictionaryInfo> page, @Param("text") String miniClassification);
    @Select("select d1.*,d2.text  as ptext from dictionary d1 \n" +
            "LEFT JOIN dictionary d2 on d2.id = d1.pid\n" +
            "where d2.text = #{text} or d1.text = #{text}\n ")
    IPage<DictionaryInfo> getListByMiddle(Page<DictionaryInfo> page, @Param("text") String middleClassification);
    @Select("select d1.*,d2.text  as ptext  from dictionary d1 \n" +
            "LEFT JOIN dictionary d2 on d2.id = d1.pid\n" +
            "where d2.text = #{text} or d1.text = #{text}\n ")
    IPage<DictionaryInfo> getListByLarge(Page<DictionaryInfo> page,@Param("text") String largeClassification);

    @Select("select d1.*,d2.text as ptext  from dictionary d1 \n" +
            "LEFT JOIN dictionary d2 on d2.id = d1.pid\n" +
            "where d1.lev = #{lev} \n ")
    List<DictionaryInfo> getPListByLev(@Param("lev") Integer lev);
    @Select("select * from dictionary where pid=30")
    List<Dictionary> selectByIds();

    @Select("select * from dictionary where pid=33")
    List<Dictionary> listByIdInsu();

    @Select("select * from dictionary where pid=58")
    List<Dictionary> listByIdRefuel();
}
